import request from '@/utils/request'
import Qs from 'qs'

export function listAssociation(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.association',
      _mt: 'page',
      ...query
    }
  })
}

export function createAssociation(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'create',
      associationDTO: JSON.stringify(data)
    })
  })
}

export function updateAssociation(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'update',
      associationDTO: JSON.stringify(data)
    })
  })
}

export function detailAssociation(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'detail',
      id: id
    })
  })
}

export function deleteAssociation(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'delete',
      id: id
    })
  })
}

export function batchDeleteAssociation(ids) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'batchDelete',
      ids: JSON.stringify(ids)
    })
  })
}

export function richTextAssociation(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'richText',
      id: id
    })
  })
}

export function queryAssociation(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'queryAssociation',
      id: id
    })
  })
}

export function deleteUser(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.association',
      _mt: 'deleteUser',
      userId: id
    })
  })
}
